package collect

import (
	"api/internal/respons"
	"api/internal/svc"
	"api/internal/types"
	"collection_srv/collectionclient"
	"context"

	"github.com/zeromicro/go-zero/core/logx"
)

type ThermometerHealthLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewThermometerHealthLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ThermometerHealthLogic {
	return &ThermometerHealthLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// 温度计测试数据报告生成
func (l *ThermometerHealthLogic) ThermometerHealth(req *types.ThermometerHealthRequest) (resp *types.Response, err error) {
	report, err := l.svcCtx.Collection.ThermometerHealth(l.ctx, &collectionclient.ThermometerHealthRequest{
		UserId: req.UserId,
	})
	if err != nil {
		return respons.Error(400, "温度计测试数据报告生成失败", err.Error()), err
	}
	return respons.Success(report), nil
}
